﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PMS.BusinessFacade;
using PMS.EntityManage;
using PMS.Common;
using PMS.EntityQuery;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using BusinessFacade;
using EntityManage;

public partial class Modules_Personal_MyAppealDetail : System.Web.UI.Page
{
    IOther_AppealHandler appealHandler = new Other_AppealManage();
    IOther_AppealAttachHandler appAttachHandler = new Other_AppealAttachManage();
    ISys_UserHandler userHandler = new Sys_UserManage();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            dataBind();
        }
    }

    private void dataBind()
    {
        if (Request["ID"] != null && Request["ID"] != string.Empty)
        {
            int ID = 0;
            int.TryParse(Request["ID"], out ID);

            if (ID != 0)
            {
                try
                {
                    Other_AppealQuery appealQuery = appealHandler.GetOther_AppealQuery(ID);
                    if (appealQuery != null)
                    {
                        lblTitle.Text = appealQuery.Title;
                        lblStatus.Text = Enums.GetOtherAppealStatus((Enums.OtherAppealStatus)appealQuery.Status);
                        lblDate.Text = appealQuery.Create_Time.ToString();
                        lblContent.InnerHtml = appealQuery.Content;

                        Other_AppealAttachQuery[] attList = appAttachHandler.GetOther_AppealAttachQueryList(" Appeal_ID = @Appeal_ID", new SqlParameter[] { new SqlParameter("@Appeal_ID", ID) });
                        StringBuilder sb = new StringBuilder();
                        if (attList != null && attList.Length > 0)
                        {
                            foreach (Other_AppealAttachQuery attQuery in attList)
                            {
                                sb.Append("<a href=\"?method=download&aid=" + attQuery.ID.ToString() + "\">");
                                sb.Append(attQuery.Name);
                                sb.Append("</a><br/>");
                            }

                            spnAttachList.InnerHtml = sb.ToString();
                        }
                    }
                }
                catch
                {
                    Jscript.Alert("操作失败!", this.Page);
                }
            }
        }
    }

}
